using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[CreateAssetMenu(menuName = "创建ScriptableObject/Effect/AddBuffEffect")]
public class AddBuffEffectData : InstantEffectData
{
    /// <summary>
    /// Buff �����ʲ�
    /// </summary>
    public BuffData BuffData;     
    
    public override void Execute(Entity caster, Entity target, params object[] args)
    {
        Logger.Log("AddBuffEffectData", $"开始执行 AddBuffEffect，caster={caster?.name}, target={target?.name}");
        
        if (BuffData == null)
        {
            Logger.LogError("AddBuffEffectData", $"BuffData 为空！caster={caster?.name}, target={target?.name}");
            return;
        }
        
        if (target == null)
        {
            Logger.LogError("AddBuffEffectData", $"目标为空！caster={caster?.name}");
            return;
        }
        
        if (target.BuffComponent == null)
        {
            Logger.LogError("AddBuffEffectData", $"目标没有 BuffComponent！target={target?.name}");
            return;
        }
        
        Logger.Log("AddBuffEffectData", $"添加Buff: {BuffData.BuffName} (类型={BuffData.BuffType}), caster={caster?.name}, target={target?.name}");
        target.BuffComponent.AddBuff(BuffData, caster, target);
        Logger.Log("AddBuffEffectData", $"AddBuff 调用完成，caster={caster?.name}, target={target?.name}");
    }
}
